//
//  TravelRouteNextViewController.m
//  HZHome
//
//  Created by Alawn on 13-10-11.
//  Copyright (c) 2013年 xzysun. All rights reserved.
//

#import "TravelRouteNextViewController.h"
#import "TravelRouteSecondCell.h"
#import "TravelViewController.h"
#import "TravelRouteInfoViewController.h"
@interface TravelRouteNextViewController ()

@end

@implementation TravelRouteNextViewController
@synthesize listRouteData;
@synthesize routeType;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    NSString *plistPath = [[NSBundle mainBundle] pathForResource:@"TravelRoute" ofType:@"plist"];
    NSDictionary *root = [[NSDictionary alloc]initWithContentsOfFile:plistPath];
    NSDictionary *TravelRoute=[root objectForKey:@"Routes"];
    if ([@"路线一" compare:routeType] == NSOrderedSame) {
        listRouteData=[TravelRoute objectForKey:@"Route1"];
    }
    if ([@"路线二" compare:routeType] == NSOrderedSame) {
        listRouteData=[TravelRoute objectForKey:@"Route2"];
    }
    if ([@"路线三" compare:routeType] == NSOrderedSame) {
        listRouteData=[TravelRoute objectForKey:@"Route3"];
    }
    if ([@"路线四" compare:routeType] == NSOrderedSame) {
        listRouteData=[TravelRoute objectForKey:@"Route4"];
    }
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [self tableView:tableView cellForRowAtIndexPath:indexPath];
    return cell.frame.size.height;
}
#pragma mark -- 实现TableView数据源方法
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return [listRouteData count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    TravelRouteSecondCell *myCell = (TravelRouteSecondCell*)[tableView dequeueReusableCellWithIdentifier:@"TravelRouteSecondCell"];
    if (myCell == nil) {
        myCell = [[[NSBundle mainBundle] loadNibNamed:@"TravelRouteSecondCell" owner:self options:nil]objectAtIndex:0];
    }
//   [myCell setAccessoryType:UITableViewCellAccessoryDisclosureIndicator];
    NSUInteger row = [indexPath row];
    NSDictionary *dictRoute=[listRouteData objectAtIndex:row];
    UIImage *img = [UIImage imageNamed:[dictRoute objectForKey:@"image"]];
    UIImageView *mimageView = [[UIImageView alloc] initWithFrame:CGRectMake(22, 147, 278, 128)];
    mimageView.image=img;
    [myCell addSubview:mimageView];
//    myCell.imageView.image=img;
    myCell.LabelTitle.text=[dictRoute objectForKey:@"item1"];
    myCell.LabelDownTitle.text=[dictRoute objectForKey:@"item1"];
    myCell.LabelContent.text=[dictRoute objectForKey:@"item2"];
    myCell.LabelStation.text=[dictRoute objectForKey:@"LabelStation"];
    [myCell setBackgroundColor:[UIColor clearColor]];
    [myCell.contentView setBackgroundColor:[UIColor clearColor]];
    return myCell;
}
#pragma mark -- 实现TableView委托方法
- (void)tableView:(UITableView *)tableView
didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    NSUInteger row = [indexPath row];
    
    TravelViewController *travelVC = [[TravelViewController alloc]initWithNibName:@"TravelViewController" bundle:nil];
    travelVC.dictRoute=[listRouteData objectAtIndex:row];
    travelVC.title=[[listRouteData objectAtIndex:row] objectForKey:@"item1"];
     travelVC.isLuxian = @"路线推荐";
   [self.navigationController pushViewController:travelVC animated:YES];
    
    
//    NSLog(@"我进来TableView委托方法");
//    TravelRouteInfoViewController *travelVC = [[TravelRouteInfoViewController alloc]initWithNibName:@"TravelRouteInfoViewController" bundle:nil];
//    
//    travelVC.dictRoute=[listRouteData objectAtIndex:row];
//    travelVC.title=[[listRouteData objectAtIndex:row] objectForKey:@"item1"];
//    
//    [self.navigationController pushViewController:travelVC animated:YES];
    
    
}

@end
